package cn.edu.hqu.javaee.Service;


import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.authority.AuthorityUtils;
//import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

import cn.edu.hqu.javaee.Entity.User;

@Component
public class UserRepositoryUserDetailsService implements UserDetailsService {

    @Autowired
    private UserService userService;
    
    @Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		User user=userService.findUserByUsername(username);
		if(user!=null) {
			return user;
		}
		throw new UsernameNotFoundException("User"+username+"not found");
	}
    

}


